<template>
	<view class="Jy_user_wechat_login_page">
		<view class="Jy_customer_my_center_top_group" :style="{ 'padding-top': statusBarHeight + 'px' }">
			<view class="back_icon_box" @click="getBack">
				<image src="http://120.78.177.187:8083/crmebimage/public/mpImage/main_menu/right.png" mode="aspectFit"></image>
			</view>
		</view>
		<view class="Jy_wechat_login_group" :style="{'height' : 'calc(100vh - 76rpx - '+ statusBarHeight + 'px)'}">
			<view class="Jy_wechat_login_box">
				<view class="main_login_group">
					<view class="main_login_box">
						<view class="lg_continer">
							<image src="http://120.78.177.187:8083/crmebimage/public/mpImage/home/logo.png" mode="aspectFit"></image>
						</view>
						<view class="lg_text_box">
							<text>英郎商城</text>
						</view>
					</view>
				</view>
				<view class="wechat_button_group">
					<view :class=" disableWechat ? 'wechat_button_disable_box' : 'wechat_button_box'" @click="tologion">
						<view class="wechat_button_image_box">
							<image src="http://120.78.177.187:8083/crmebimage/public/mpImage/login/wechat.png" mode="aspectFill"></image>
						</view>
						<view class="wechat_button_text_box">
							<text>微信授权登录</text>
						</view>
					</view>
				</view>
				<view class="wechat_sm_group">
					<view class="wechat_sm_check_box">
						<u-checkbox-group
						            v-model="checkboxValue1"
						            placement="column"
						            @change="checkboxChange"
								shape="circle"
								activeColor="#04BE02"
						        >
						            <u-checkbox
						                :customStyle="{marginBottom: '8px'}"
						                v-for="(item, index) in checkboxList1"
						                :key="index"
						                :name="item.name"
						            >
						            </u-checkbox>
						</u-checkbox-group>
					</view>
					<view class="wechat_sm_text_box"> 
						<text>登录/注册即代表您同意</text>
						<text class="active" @click="getAuthPage(0)">《用户服务协议》</text>
						<text>和</text>
						<text class="active" @click="getAuthPage(1)">《隐私政策权》</text>
						<text>和</text>
						<text class="active" @click="getAuthPage(2)">《个人信息授权与保护声明》</text>
					</view>
				</view>
				
				<view class="account-login_box" @click="getAccountLogin()">
					<text>账号密码登录</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				// 适配头部导航高度
				statusBarHeight: getApp().globalData.statusBarHeight,
				checkboxValue1:[],
				// 协议未勾选禁用微信授权登录
				disableWechat: true,
				checkboxList1: [
					{
						name: '同意',
				            disabled: false
				      }      
				],
			};
		},
		methods: {
			
			tologion(){
				let that = this
				wx.login({
				  success (res) {
				    if (res.code) {
				      //发起网络请求
					  that.sendRequest({
					  	url: "/api/front/wechat/authorize/program/login",
					  	data: {
					  	  code: res.code
					  	},
					  	method: 'post',
					  	success: res => {
					  		if (res.data.data) {
								console.log(JSON.stringify(res.data.data))
					  
					  		}
					  	}
					  })
				     
				    } else {
				      console.log('登录失败！' + res.errMsg)
				    }
				  }
				})
			},
			// 返回上一步
			getBack() {
				uni.navigateBack()
			},
			// 勾选协议
			checkboxChange(n) {
			      this.disableWechat = n.length > 0 ? false : true
			},
			// 跳转到协议页面
			getAuthPage(e) {
				let pageurl = '';
				pageurl = e === 0 ? '/pagesA/main/customerMyCenter/userServiceAgreement/userServiceAgreement' : 
				e === 1 ? '/pagesA/main/customerMyCenter/privacyPolicy/privacyPolicy' : 
				'/pagesA/main/customerMyCenter/personInfoAuth/personInfoAuth';
				uni.navigateTo({
					url: pageurl
				})
			},
			// 跳转到账号密码登录
			getAccountLogin() {
				uni.navigateTo({
					url: '/pagesA/main/customerMyCenter/accountLogin/accountLogin'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
@import 'userWechatLogin.scss';
</style>
